package com.b2.controller.web;

import com.b2.pojo.dto.BookCategoryDTO;
import com.b2.pojo.entity.BookCategory;
import com.b2.result.Result;
import com.b2.service.BookCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/web/BookCategory")
@Slf4j
@Api(tags = "书本分类相关接口")
@CrossOrigin
public class BookCategoryController {



    @Autowired
    private BookCategoryService bookCategoryService;


    @ApiOperation("查看当前用户的书本类型")
    @GetMapping("/check")
    public Result<List<BookCategory>> check() {

        return bookCategoryService.check();
    }
    @ApiOperation("删除书本类型")
    @DeleteMapping("/delete")
    public Result delete(Long id) {
        return bookCategoryService.delete(id);
    }
    @ApiOperation("添加书本类型")
    @PostMapping("/add")
    public Result add(String name) {
        return bookCategoryService.add(name);
    }
}
